package com.ruoyi.platform.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.platform.domain.Regions;
import com.ruoyi.platform.service.IRegionsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 覆盖区域Controller
 * 
 * @author ruoyi
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/platform/regions")
public class RegionsController extends BaseController
{
    @Autowired
    private IRegionsService regionsService;

    /**
     * 查询覆盖区域列表
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:list')")
    @GetMapping("/list")
    public TableDataInfo list(Regions regions)
    {
        startPage();
        List<Regions> list = regionsService.selectRegionsList(regions);
        return getDataTable(list);
    }

    /**
     * 导出覆盖区域列表
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:export')")
    @Log(title = "覆盖区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Regions regions)
    {
        List<Regions> list = regionsService.selectRegionsList(regions);
        ExcelUtil<Regions> util = new ExcelUtil<Regions>(Regions.class);
        util.exportExcel(response, list, "覆盖区域数据");
    }

    /**
     * 获取覆盖区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:query')")
    @GetMapping(value = "/{regionId}")
    public AjaxResult getInfo(@PathVariable("regionId") String regionId)
    {
        return success(regionsService.selectRegionsByRegionId(regionId));
    }

    /**
     * 新增覆盖区域
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:add')")
    @Log(title = "覆盖区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Regions regions)
    {
        return toAjax(regionsService.insertRegions(regions));
    }

    /**
     * 修改覆盖区域
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:edit')")
    @Log(title = "覆盖区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Regions regions)
    {
        return toAjax(regionsService.updateRegions(regions));
    }

    /**
     * 删除覆盖区域
     */
    @PreAuthorize("@ss.hasPermi('platform:regions:remove')")
    @Log(title = "覆盖区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionIds}")
    public AjaxResult remove(@PathVariable String[] regionIds)
    {
        return toAjax(regionsService.deleteRegionsByRegionIds(regionIds));
    }
}
